package com.gxa.service.impl.fygl.sfxmwh;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.gxa.mapper.fygl.sfxmwh.CharTypeMapper;
import com.gxa.pojo.dto.fygl.sfxmwh.CharTypeDto;
import com.gxa.pojo.entity.fygl.sfxmwh.CharType;
import com.gxa.service.fygl.sfxmwh.QueryAllService;
import com.gxa.utils.QueryResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author：hubalabala
 */
@Service
public class QueryAllServiceImpl implements QueryAllService {
    @Resource
    private CharTypeMapper charTypeMapper;

    @Override
    public QueryResult queryAll(CharTypeDto charTypeDto) {
        Page<CharType> page = PageHelper.startPage(charTypeDto.getPage(),charTypeDto.getLimit());
        List<CharType> charTypeList = charTypeMapper.queryAll(charTypeDto);

        QueryResult queryResult = new QueryResult();
        queryResult.setCount(page.getTotal());
        queryResult.setData(charTypeList);
        return queryResult;
    }

    @Override
    public void add(CharType charType) {
        charTypeMapper.insertCharType(charType);
    }

    @Override
    public void update(CharType charType) {
        charTypeMapper.updateCharType(charType);
    }

    @Override
    public void delete(String proName) {
        charTypeMapper.deleteCharType(proName);
    }

    @Override
    public QueryResult findByName(CharTypeDto charTypeDto) {
        Page<CharType> page = PageHelper.startPage(charTypeDto.getPage(),charTypeDto.getLimit());
        List<CharType> charTypeList = charTypeMapper.queryByProName(charTypeDto);

        QueryResult queryResult = new QueryResult();
        queryResult.setCount(page.getTotal());
        queryResult.setData(charTypeList);
        return queryResult;
    }
}
